Improve previous commit a bit, use better variable names.
authorTor Lillqvist <tml@src.gnome.org>
Sat, 12 Aug 2000 07:37:27 +0000 (07:37 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Sat, 12 Aug 2000 07:37:27 +0000 (07:37 +0000)
gtk/gtkfilesel.c

index 18f8896cf573342895ae8a6f437f2f68d7e8f958..e30a2121b51e2ef284ae5ef580535bbda87a0f23 100644 (file)
@@ -730,7 +730,7 @@ gtk_file_selection_get_filename (GtkFileSelection *filesel)
 {
   static gchar nothing[2] = "";
   static gchar something[MAXPATHLEN*2];
-  char *filename;
+  char *sys_filename;
   char *text;
 
   g_return_val_if_fail (filesel != NULL, nothing);
@@ -742,9 +742,9 @@ gtk_file_selection_get_filename (GtkFileSelection *filesel)
   text = gtk_entry_get_text (GTK_ENTRY (filesel->selection_entry));
   if (text)
     {
-      filename = g_filename_from_utf8 (cmpl_completion_fullname (text, filesel->cmpl_state));
-      strncpy (something, filename, sizeof (something));
-      g_free (filename);
+      sys_filename = g_filename_from_utf8 (cmpl_completion_fullname (text, filesel->cmpl_state));
+      strncpy (something, sys_filename, sizeof (something));
+      g_free (sys_filename);
       return something;
     }
 
@@ -881,7 +881,7 @@ gtk_file_selection_create_dir_confirmed (GtkWidget *widget,
   gchar *dirname;
   gchar *path;
   gchar *full_path;
-  gchar *xpath;
+  gchar *sys_full_path;
   gchar *buf;
   CompletionState *cmpl_state;
   
@@ -893,15 +893,15 @@ gtk_file_selection_create_dir_confirmed (GtkWidget *widget,
   path = cmpl_reference_position (cmpl_state);
   
   full_path = g_strconcat (path, G_DIR_SEPARATOR_S, dirname, NULL);
-  xpath = g_filename_from_utf8 (full_path);
-  if (mkdir (xpath, 0755) < 0) 
+  sys_full_path = g_filename_from_utf8 (full_path);
+  if (mkdir (sys_full_path, 0755) < 0) 
     {
       buf = g_strconcat ("Error creating directory \"", dirname, "\":  ", 
                         g_strerror (errno), NULL);
       gtk_file_selection_fileop_error (fs, buf);
     }
   g_free (full_path);
-  g_free (xpath);
+  g_free (sys_full_path);
   
   gtk_widget_destroy (fs->fileop_dialog);
   gtk_file_selection_populate (fs, "", FALSE);
@@ -986,7 +986,7 @@ gtk_file_selection_delete_file_confirmed (GtkWidget *widget,
   CompletionState *cmpl_state;
   gchar *path;
   gchar *full_path;
-  gchar *xpath;
+  gchar *sys_full_path;
   gchar *buf;
   
   g_return_if_fail (fs != NULL);
@@ -996,15 +996,15 @@ gtk_file_selection_delete_file_confirmed (GtkWidget *widget,
   path = cmpl_reference_position (cmpl_state);
   
   full_path = g_strconcat (path, G_DIR_SEPARATOR_S, fs->fileop_file, NULL);
-  xpath = g_filename_from_utf8 (full_path);
-  if (unlink (xpath) < 0) 
+  sys_full_path = g_filename_from_utf8 (full_path);
+  if (unlink (sys_full_path) < 0) 
     {
       buf = g_strconcat ("Error deleting file \"", fs->fileop_file, "\":  ", 
                         g_strerror (errno), NULL);
       gtk_file_selection_fileop_error (fs, buf);
     }
   g_free (full_path);
-  g_free (xpath);
+  g_free (sys_full_path);
   
   gtk_widget_destroy (fs->fileop_dialog);
   gtk_file_selection_populate (fs, "", FALSE);
@@ -1098,6 +1098,8 @@ gtk_file_selection_rename_file_confirmed (GtkWidget *widget,
   gchar *path;
   gchar *new_filename;
   gchar *old_filename;
+  gchar *sys_new_filename;
+  gchar *sys_old_filename;
   CompletionState *cmpl_state;
   
   g_return_if_fail (fs != NULL);
@@ -1110,7 +1112,10 @@ gtk_file_selection_rename_file_confirmed (GtkWidget *widget,
   new_filename = g_strconcat (path, G_DIR_SEPARATOR_S, file, NULL);
   old_filename = g_strconcat (path, G_DIR_SEPARATOR_S, fs->fileop_file, NULL);
 
-  if (rename (old_filename, new_filename) < 0) 
+  sys_new_filename = g_filename_from_utf8 (new_filename);
+  sys_old_filename = g_filename_from_utf8 (old_filename);
+
+  if (rename (sys_old_filename, sys_new_filename) < 0) 
     {
       buf = g_strconcat ("Error renaming file \"", file, "\":  ", 
                         g_strerror (errno), NULL);
@@ -1118,6 +1123,8 @@ gtk_file_selection_rename_file_confirmed (GtkWidget *widget,
     }
   g_free (new_filename);
   g_free (old_filename);
+  g_free (sys_new_filename);
+  g_free (sys_old_filename);
   
   gtk_widget_destroy (fs->fileop_dialog);
   gtk_file_selection_populate (fs, "", FALSE);
@@ -2172,7 +2179,7 @@ open_new_dir (gchar       *dir_name,
   gint i;
   struct stat ent_sbuf;
   GString *path;
-  gchar *xdir;
+  gchar *sys_dir_name;
 
   sent = g_new (CompletionDirSent, 1);
   sent->mtime = sbuf->st_mtime;
@@ -2181,13 +2188,13 @@ open_new_dir (gchar       *dir_name,
 
   path = g_string_sized_new (2*MAXPATHLEN + 10);
 
-  xdir = g_filename_from_utf8 (dir_name);
-  directory = opendir (xdir);
+  sys_dir_name = g_filename_from_utf8 (dir_name);
+  directory = opendir (sys_dir_name);
 
   if (!directory)
     {
       cmpl_errno = errno;
-      g_free (xdir);
+      g_free (sys_dir_name);
       return NULL;
     }
 
@@ -2207,13 +2214,13 @@ open_new_dir (gchar       *dir_name,
        {
          cmpl_errno = errno;
          closedir (directory);
-         g_free (xdir);
+         g_free (sys_dir_name);
          return NULL;
        }
 
       sent->entries[i].entry_name = g_filename_to_utf8 (dirent_ptr->d_name);
 
-      g_string_assign (path, xdir);
+      g_string_assign (path, sys_dir_name);
       if (path->str[path->len-1] != G_DIR_SEPARATOR)
        {
          g_string_append_c (path, G_DIR_SEPARATOR);
@@ -2234,7 +2241,7 @@ open_new_dir (gchar       *dir_name,
        sent->entries[i].is_dir = 1;
     }
 
-  g_free (xdir);
+  g_free (sys_dir_name);
   g_string_free (path, TRUE);
   qsort (sent->entries, sent->entry_count, sizeof (CompletionDirEntry), compare_cmpl_dir);
 
@@ -2266,7 +2273,7 @@ check_dir (gchar       *dir_name,
 
   static const gint n_no_stat_dirs = G_N_ELEMENTS (no_stat_dirs);
   static gboolean initialized = FALSE;
-  gchar *xdir;
+  gchar *sys_dir_name;
   gint i;
 
   if (!initialized)
@@ -2279,14 +2286,14 @@ check_dir (gchar       *dir_name,
        }
     }
 
-  xdir = g_filename_from_utf8 (dir_name);
-  if (stat (xdir, result) < 0)
+  sys_dir_name = g_filename_from_utf8 (dir_name);
+  if (stat (sys_dir_name, result) < 0)
     {
-      g_free (xdir);
+      g_free (sys_dir_name);
       cmpl_errno = errno;
       return FALSE;
     }
-  g_free (xdir);
+  g_free (sys_dir_name);
 
   *stat_subdirs = TRUE;
   for (i = 0; i < n_no_stat_dirs; i++)
@@ -2373,7 +2380,7 @@ correct_dir_fullname (CompletionDir* cmpl_dir)
 {
   gint length = strlen (cmpl_dir->fullname);
   gchar *first_slash = strchr (cmpl_dir->fullname, G_DIR_SEPARATOR);
-  gchar *xfilename;
+  gchar *sys_filename;
   struct stat sbuf;
 
   /* Does it end with /. (\.) ? */
@@ -2412,14 +2419,14 @@ correct_dir_fullname (CompletionDir* cmpl_dir)
          return TRUE;
        }
 
-      xfilename = g_filename_from_utf8 (cmpl_dir->fullname);
-      if (stat (xfilename, &sbuf) < 0)
+      sys_filename = g_filename_from_utf8 (cmpl_dir->fullname);
+      if (stat (sys_filename, &sbuf) < 0)
        {
-         g_free (xfilename);
+         g_free (sys_filename);
          cmpl_errno = errno;
          return FALSE;
        }
-      g_free (xfilename);
+      g_free (sys_filename);
 
       cmpl_dir->fullname[length - 3] = 0;
 
@@ -2440,14 +2447,14 @@ correct_dir_fullname (CompletionDir* cmpl_dir)
          return TRUE;
        }
 
-      xfilename = g_filename_from_utf8 (cmpl_dir->fullname);
-      if (stat (xfilename, &sbuf) < 0)
+      sys_filename = g_filename_from_utf8 (cmpl_dir->fullname);
+      if (stat (sys_filename, &sbuf) < 0)
        {
-         g_free (xfilename);
+         g_free (sys_filename);
          cmpl_errno = errno;
          return FALSE;
        }
-      g_free (xfilename);
+      g_free (sys_filename);
 
       cmpl_dir->fullname[length - 4] = 0;
 
@@ -2468,7 +2475,7 @@ correct_parent (CompletionDir *cmpl_dir,
   gchar *last_slash;
   gchar *first_slash;
   gchar *new_name;
-  gchar *xfilename;
+  gchar *sys_filename;
   gchar c = 0;
 
   last_slash = strrchr (cmpl_dir->fullname, G_DIR_SEPARATOR);
@@ -2488,16 +2495,16 @@ correct_parent (CompletionDir *cmpl_dir,
       last_slash[1] = 0;
     }
 
-  xfilename = g_filename_from_utf8 (cmpl_dir->fullname);
-  if (stat (xfilename, &parbuf) < 0)
+  sys_filename = g_filename_from_utf8 (cmpl_dir->fullname);
+  if (stat (sys_filename, &parbuf) < 0)
     {
-      g_free (xfilename);
+      g_free (sys_filename);
       cmpl_errno = errno;
       if (!c)
        last_slash[0] = G_DIR_SEPARATOR;
       return FALSE;
     }
-  g_free (xfilename);
+  g_free (sys_filename);
 
 #ifndef G_OS_WIN32             /* No inode numbers on Win32 */
   if (parbuf.st_ino == sbuf->st_ino && parbuf.st_dev == sbuf->st_dev)
@@ -2531,23 +2538,23 @@ find_parent_dir_fullname (gchar* dirname)
 {
   gchar *orig_dir;
   gchar *result;
-  gchar *xcwd;
-  gchar *xdir;
+  gchar *sys_cwd;
+  gchar *sys_dirname;
 
   orig_dir = g_get_current_dir ();
 
-  xdir = g_filename_from_utf8 (dirname);
-  if (chdir (xdir) != 0 || chdir ("..") != 0)
+  sys_dirname = g_filename_from_utf8 (dirname);
+  if (chdir (sys_dirname) != 0 || chdir ("..") != 0)
     {
-      g_free (xdir);
+      g_free (sys_dirname);
       cmpl_errno = errno;
       return NULL;
     }
-  g_free (xdir);
+  g_free (sys_dirname);
 
-  xcwd = g_get_current_dir ();
-  result = g_filename_to_utf8 (cwd);
-  g_free (xcwd);
+  sys_cwd = g_get_current_dir ();
+  result = g_filename_to_utf8 (sys_cwd);
+  g_free (sys_cwd);
 
   if (chdir (orig_dir) != 0)
     {